<script setup lang="ts">
import { OrderType } from '@/enums'
import type { MedicalOrderItem } from '@/types/medicine'
import { useRouter } from 'vue-router'
const props = defineProps<{
  item: MedicalOrderItem
}>()

// 查看处方

// 点击跳转详情
const router = useRouter()
const goDetail = (item: MedicalOrderItem) => {
  router.push(`/medicine/${item.id}`)
}
const MedicineOrderStatusMap = [
  {
    label: 10,
    value: '未支付',
  },
  {
    label: 11,
    value: '待发货',
  },
  {
    label: 12,
    value: '待收货',
  },
  {
    label: 13,
    value: '已完成',
  },
  {
    label: 14,
    value: '已取消',
  },
]
</script>

<template>
  <div class="consult-item">
    <div class="head van-hairline--bottom">
      <img class="img" src="@/assets/prescription.svg" />
      <p>药品订单</p>
      <span
        :class="{
          orange: item.status === OrderType.MedicinePay,
          green: item.status === OrderType.MedicineSend,
        }"
        >{{ MedicineOrderStatusMap.find((i) => i.label === item.status)?.value }}</span
      >
    </div>
    <!-- 订单信息 -->
    <div class="body" @click="goDetail(item)">
      <!-- <div class="body-row">
        <div class="body-label">收货人</div>
        <div class="body-value tip">{{ item.address.receiver }}</div>
      </div>
      <div class="body-row">
        <div class="body-label">收货人手机号</div>
        <div class="body-value">
          {{ item.address.mobile }}
        </div>
      </div>
      <div class="body-row">
        <div class="body-label">收货地址</div>
        <div class="body-value">
          {{ item.address.province }} {{ item.address.city }} {{ item.address.addressDetail }}
        </div>
      </div> -->
      <div class="body-row">
        <div class="body-label">订单编号</div>
        <div class="body-value tip">{{ item.orderNo }}</div>
      </div>
      <div class="body-row">
        <div class="body-label">药品</div>
        <div class="body-value tip">
          {{ item.medicines.map((i) => `${i.name} * ${i.quantity}`).join('、') }}
        </div>
      </div>
      <div class="body-row">
        <div class="body-label">药品金额</div>
        <div class="body-value tip">
          {{
            (
              Number(item.actualPayment) +
              item.expressFee +
              item.couponDeduction +
              item.pointDeduction
            ).toFixed(2)
          }}
        </div>
      </div>
      <div class="body-row">
        <div class="body-label">运费</div>
        <div class="body-value">
          {{ item.expressFee }}
        </div>
      </div>
      <div class="body-row">
        <div class="body-label">优惠券</div>
        <div class="body-value">
          {{ item.couponDeduction }}
        </div>
      </div>
      <div class="body-row">
        <div class="body-label">实付款</div>
        <div class="body-value price">
          {{ item.actualPayment }}
        </div>
      </div>
      <div class="body-row">
        <div class="body-label">支付方式</div>
        <div class="body-value">
          {{ item.paymentMethod === 0 ? '微信支付' : '支付宝支付' }}
        </div>
      </div>
    </div>
    <!-- 1. 未购买：去购买 -->
    <!-- 2. -->
    <!-- <div class="foot" v-if="item.status === PrescriptionStatus.Payment">
      <van-button class="gray" plain size="small" round @click="showPrescription(item.id)"
        >查看原始处方
      </van-button>
      <van-button type="primary" plain size="small" round :to="`/medicine/${item.medicineOrderId}`">
        订单详情
      </van-button>
    </div> -->
  </div>
</template>

<style lang="scss" scoped>
.consult-item {
  border-radius: 4px;
  box-shadow: 0px 0px 22px 0px rgba(245, 245, 245, 0.1);
  background-color: #fff;
  margin-bottom: 10px;
  .head {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 15px;
    .img {
      width: 20px;
      height: 20px;
    }
    > p {
      flex: 1;
      font-size: 15px;
      padding-left: 10px;
    }
    > span {
      color: var(--cp-tag);
      &.orange {
        color: #f2994a;
      }
      &.green {
        color: var(--cp-primary);
      }
    }
  }
  .body {
    padding: 15px 15px 8px 15px;
    .body-row {
      display: flex;
      margin-bottom: 7px;
    }
    .body-label {
      width: 62px;
      font-size: 13px;
      color: var(--cp-tip);
    }
    .body-value {
      width: 250px;
      color: var(--cp-text3);
      &.price {
        color: var(--cp-price);
      }
      &.tip {
        color: var(--cp-text2);
      }
    }
  }
  .foot {
    padding: 0 15px 15px 15px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    .van-button {
      margin-left: 10px;
      padding: 0 16px;
      &.gray {
        color: var(--cp-text3);
        background-color: var(--cp-bg);
      }
    }
    .more {
      color: var(--cp-tag);
      flex: 1;
      font-size: 13px;
    }
  }
}
</style>
